<?php
namespace app\index\controller;
use think\Db;
class Gcat extends Base
{   
    public function lists($id=0 ){
        $info = Db::name('goods_cat')->find($id);
        
        $temp = [];
        if($info['parent_id']){
            $rs = Db::name('goods_cat')->where('parent_id', $info['parent_id'])->select();
            $temp['全部'] = $info['parent_id'];
            foreach($rs as $v){
                $temp[$v['cat_title']] = $v['id'];
            }
        }else{
            $rs    = Db::name('goods_cat')->where('parent_id', $id)->select();
            $temp['全部'] = $info['id'];
            foreach($rs as $v){
                $temp[$v['cat_title']] = $v['id'];
            }
        }
        
        $data = [
            'id'   => $id,
            'nav'  => $temp,
            'info' => $info,
        ];
        return view('', $data);
    }
}